home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / falcon / falclib.lzh / ROUTS / WINDOW.S < prev    next >
Encoding:
Text File  |  1994-08-16  |  3.7 KB  |  177 lines

  1. *
  2. * WINDOW.S
  3. *  (vdilib.i & aeslib.i must be included at the end of the program)
  4. *
  5. *    @createwindow
  6. *
  7. *    Creates a simple gem window. It also initialises the application.
  8. *
  9. * In    wtype equ %info move full close name
  10. *    xstart,ystart,xwidth,ywidth,windowname(string terminated by 0)
  11. * Out    w_handle,ap_id
  12. *    (destroys a lot)
  13. *
  14. *    @recalcwindow
  15. *     Recalculates the window size.
  16. *    (destroys a lot)
  17. *
  18. *    @moveit
  19. *     Moves the window. May be called at every vm_moved(=28) event.
  20. * In     a0.l=adr to messagebuffer
  21. *    (destroys a lot)
  22. *
  23. *    @drawrsrc
  24. *     Draws the rsrc.
  25. *     This function draw doesn't care about clipping, so you should probably not use it.
  26. * In     a0.l=adr to rsrc
  27. *    (destroys a lot)
  28. *
  29. *    @updatersrc
  30. *     Draws the rsrc. Use this when receiving update events(=20).
  31. *     This function takes care of all clipping.
  32. * In     a0.l=adr to rsrc
  33. *    (destroys a lot)
  34. *
  35. *    @topwindow
  36. *     Activates the window. May be called at every vm_topped(=21) event.
  37. * In     a0.l=adr to messagebuffer
  38. *    (destroys a lot)
  39. *
  40. *    @bottomwindow
  41. *     Bottoms the window if it's mine. May be called at every vm_bottomed(=33) event.
  42. * In     a0.l=adr to messagebuffer 
  43. *    (destroys a lot)
  44. *
  45. *    @button
  46. *     Returns the object number that was clicked on. This function may be called
  47. *     at every mousebutton event.
  48. * In     a0.l=adr. to rsrc
  49. *     (It automatically takes the x and y coordinates from int_out)
  50. * Out     d0.w=object that was pressed or -1.
  51. *    (destroys a lot)
  52. *
  53.  
  54.  
  55.     include    gemmacro.i
  56.  
  57.  
  58. @createwindow
  59.     appl_init
  60.     move.w    d0,ap_id        store the application id
  61.  
  62.     graf_handle
  63.     move.w    d0,current_handle    Desktop's VDI handle
  64.  
  65. * start by opening a virtual workstation
  66.     lea    intin,a0
  67.     moveq    #10-1,d0        -1 for DBF
  68. .fill    move.w    #1,(a0)+        most params are 1
  69.     dbf    d0,.fill
  70.     move.w    #2,(a0)+        use RC system
  71.  
  72.     v_opnvwk            open it
  73.  
  74. * set the mouse to an arrow
  75.     graf_mouse    #0        arrow please
  76.  
  77. * we want to open a window, so find the usable size of the screen
  78.     wind_get    #0,#4        work area of Desktop
  79.  
  80. * and create the window
  81.     wind_create    #wtype,xstart,ystart,xwidth,ywidth
  82.     move.w    d0,w_handle        save the handle (error checks?)
  83.  
  84. * now set its title
  85.     move.l    #windowname,int_in+4
  86.     wind_set    w_handle,#2    title string
  87.  
  88. * now actually show it by opening
  89.     movem.w    xstart,d0-d3
  90.     wind_open    w_handle,d0,d1,d2,d3
  91.  
  92.     bsr    @recalcwindow
  93.     rts
  94.  
  95.  
  96. * calculate the work area of the window
  97. @recalcwindow
  98.     wind_get    w_handle,#4    get work area
  99.     movem.w    int_out+2,d0-d3
  100.     movem.w    d0-d3,xstart
  101.     rts
  102.  
  103.  
  104. @moveit    
  105.     move.w    6(a0),d0
  106.     cmp.w    w_handle,d0
  107.     bne    .ut            not my window!
  108.     move.w    8(a0),int_in+4        new x pos
  109.     move.w    10(a0),int_in+6        new y pos
  110.     move.w    12(a0),int_in+8        width
  111.     move.w    14(a0),int_in+10    heigth
  112.     wind_set    w_handle,#5
  113.     bsr    @recalcwindow
  114. .ut    rts
  115.  
  116. @drawrsrc    move    xstart,16(a0)
  117.         move    ystart,18(a0)
  118.         objc_draw a0,#0,#10,xstart,ystart,xwidth,ywidth
  119.         rts
  120.  
  121. @button        move    xstart,16(a0)
  122.         move    ystart,18(a0)
  123.         objc_find a0,#0,#10,int_out+2,int_out+4
  124.         move    int_out,d0
  125.         rts
  126.  
  127. @updatersrc    move    xstart,16(a0)
  128.         move    ystart,18(a0)
  129.         move.l    a0,a6
  130.         wind_update #1
  131.         wind_get w_handle,#11
  132.         tst.w    int_out+6
  133.         bne    .next
  134.         tst.w    int_out+8
  135.         beq    .out
  136. .next        objc_draw a6,#0,#10,int_out+2,int_out+4,int_out+6,int_out+8
  137.         wind_get w_handle,#12
  138.         tst.w    int_out+6
  139.         bne    .next
  140.         tst.w    int_out+8
  141.         bne    .next
  142. .out        wind_update #0
  143.         rts
  144.         
  145. @topwindow    
  146.         move.w    6(a0),d0
  147.         cmp.w    w_handle,d0
  148.         bne    .ut            not my window!
  149.         wind_set    w_handle,#10
  150. .ut        rts
  151.  
  152. @bottomwindow
  153.         move.w    6(a0),d0
  154.         cmp.w    w_handle,d0
  155.         bne    .ut            not my window!
  156.         wind_set    w_handle,#25
  157. .ut        rts
  158.  
  159. @exitwindow    wind_close    w_handle
  160.         wind_delete    w_handle
  161.         rts
  162.  
  163.         
  164.  
  165.  
  166. * these have to remain together
  167. xstart    ds.w 1
  168. ystart    ds.w 1
  169. xwidth    ds.w 1
  170. ywidth    ds.w 1
  171.  
  172. w_handle    ds.w 1
  173. ws_handle    ds.w 1
  174. ap_id        ds.w 1
  175.  
  176.  
  177.